﻿// © Benn Eichhorn 2010
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Algobox.Feeds.Finance.Chix.CHIXMD.Messages
{
    /// <summary>
    /// Chi-X login rejected message
    /// </summary>
    public class LoginReject : IMessage
    {
        public LoginReject(char reason)            
        {        
            ReasonChar = reason;

            switch (reason)
            {
                case 'A':
                    Reason = RejectReasons.InvalidUsernamePassword;
                    break;
                case 'S':
                    Reason = RejectReasons.InvalidSession;
                    break;
                default:
                    Reason = RejectReasons.UnhandledRejectReason;
                    break;
            }
        }

        public char MessageType { get { return 'J'; } }

        /// <summary>
        /// Reason the login was rejected: A – Invalid username/password, S – Invalid session
        /// </summary>
        public char ReasonChar { get; private set; }

        /// <summary>
        /// Reason the login was rejected
        /// </summary>
        public RejectReasons Reason { get; private set; }

        public enum RejectReasons
        {
            UnhandledRejectReason,
            InvalidUsernamePassword,
            InvalidSession
        }

        public override string ToString()
        {
            return "IMessage->Debug:Reason=" + Reason.ToString();
        }
        
    }
}
